<?php



function form_user($area = false){   
 
    
    if($area){

        $action = "index2.php?seccion=user&op=update";
        $btnSubmit = $_SESSION['user']['mensaje']['update_text'];
    }else{
        $action = "index2.php?seccion=user&op=save";
        $btnSubmit = $_SESSION['user']['mensaje']['save_text'];
    }

?>
     <script>
          $("#formulario").ready(function(){                                                 
            $("#formulario").validate({
                rules:{
                    nombre: {
                        required: true
                    }
                },
                messages:{
                    nombre:{
                        required: "(*) INGRESAR!"
                    }
                },
                submitHandler: function(form) {
                    enviarFormulario('<?=$action?>','at');
                }
            });      
      });
    </script>
        
        <form method="POST"  name="formulario" id="formulario" >
    <?
    if($area){
        ?>
    <input type="hidden" name="id" value="<?=$id?>" />
        <?
    }
    ?>
    <table id="tableFormUser">
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
        <tr class="tb">
            <td class="tb11">user_id</td>
            <td class="tb11"><input type="text" name="user_id" id="user_id" value="<?=$user_id?>"  style=" width: 240px;" /></td>
        </tr>
        <tr class="tb">
            <td class="tb11">user_name</td>
            <td class="tb11"><input type="text" name="user_name" id="user_name" value="<?=$user_name?>"  style=" width: 240px;" /></td>
        </tr>
        <tr class="tb">
            <td class="tb11">user_g_id</td>
            <td class="tb11"><input type="text" name="user_g_id" id="user_g_id" value="<?=$user_g_id?>"  style=" width: 240px;" /></td>
        </tr>
        <tr class="tb">
            <td class="tb11">user_ut_id</td>
            <td class="tb11"><input type="text" name="user_ut_id" id="user_ut_id" value="<?=$user_ut_id?>"  style=" width: 240px;" /></td>
        </tr>
        <tr class="tb">
            <td class="tb11">user_status</td>
            <td class="tb11"><input type="text" name="user_status" id="user_status" value="<?=$user_status?>"  style=" width: 240px;" /></td>
        </tr>
        <tr class="tb">
            <td  class="tb11"colspan="2">
				<center>
					<input type="submit" value="<?=$btnSubmit?>"/>
				</center>
			</td>
        </tr>
        <tr>
            <td colspan="2" class="tb11"><center>-------------</center></td>
        </tr>
    </table>
</form>
<?
}  
    
    

function list_user($data, $msj=false, $dataTotal=false, $arrCb= false){
   
    if(!is_null($data)){
        $start = 1;
        if(isset ($_REQUEST["page"])){
            $start = $_REQUEST["page"];
        }
    $pages = ceil($dataTotal / 10);
      
    ?>
       <script type="text/javascript">
            $(function() {
            $("#paginador").paginate({
                count: <?=$pages?>,
                start: <?=$start?>,
                display: 3,
                border: true,
                border_color: '#5386a3',
                text_color: '#fff',
                background_color: '#5386a3',	
                border_hover_color: '#fa5909',
                text_hover_color: '#fff',
                background_hover_color	: '#fa5909', 
                images: true,
                mouse: 'press',
                onChange: function(page){                    
                    return enviarFormulario('index2.php?seccion=user&op=list&page='+page,'attriaje');
                }
            });
        });

        </script>
       
<?
    }
?>
    <script type="text/javascript">

    $(document).ready(function(){
        $("#TablaPaginador td").css("border-style", "none");
        $("#TablaPaginador td").css("border-color", "#eaeef2");        
        $("#TablaPaginador td").css("vertical-align", "middle"); 
        
        //Filtros busqueda
        $("#TablaFiltros td").css("border-style", "none");
        $("#TablaFiltros td").css("border-color", "#eaeef2");        
        $("#TablaFiltros td").css("vertical-align", "middle"); 
        $("#TablaFiltros td").css("padding", "4px"); 
                
        $("#estado").selectOptions('<?=$_REQUEST['estado']?>', true);
        
        $("#sede option").eq('').text("Todas");
                
        $("#filtro").css("width","200px");
        $("#estado").css("width","200px");
    });
    </script>
    <br/>
<form method="POST" onsubmit="return enviarFormulario('index2.php?seccion=user&op=list','attriaje');" name="formulario" id="formulario">
    <fieldset style="width: 50%;">
            <legend><b><?=$_SESSION['user']['mensaje']['filtro_head']?></legend>        
                <table id="TablaFiltros">                    
                    <tr>
                        <td> <b><?=$_SESSION['user']['mensaje']['filtro_desc']?> :<b/> </td>
                        <td> <input type="text" id="filtro" name="filtro" value="<?=$_REQUEST["filtro"]?>" /> </td>                
                    </tr>
                    <tr>
                        <td> <b><?=$_SESSION['user']['mensaje']['filtro_estado']?> :</b> </td>
                        <td> <select id="estado" name="estado" >
                                <option value="99"><?=$_SESSION['user']['mensaje']['filtro_estado_all']?></option>
                        <?
                            foreach ($arrCb['estado'] as $key => $value) {
                                ?>
                                <option value="<?=$key?>"><?=$value?></option>
                                <?
                            }
                        ?>
                            </select>
                        </td>                
                    </tr>
                    <tr>
                        <td colspan="2"></td>
                    </tr>
                    <tr>
                        <td colspan="2"> <input type="submit" value="<?=$_SESSION['user']['mensaje']['search']?>"  /> </td>
                    </tr>
                </table>
            <br/>
        </fieldset>
</form> 
        <br/>
        
        <table width="100%" id="TablaPaginador" >
            <tr>
                <td width="35%">
                    <font color="blue">
                    <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                        <?=$_SESSION['user']['mensaje']['total']?>: <?=$dataTotal?> <?=$_SESSION['user']['mensaje']['texto']?>
                    </b>
                   </font>
                </td>
                <td>
                     <div id="paginador"> </div>                    
                </td>
            </tr>
        </table>  
    <?
    if($msj){
        ?>
        <b><?=$msj?></b>
        <script type="text/javascript">
            $("#alertzone").fadeOut(10000);                                    
        </script>
        <?
    }
    if(!is_null($data)){
        include_once 'recursos/TablaDatos.php';
        $TABLA = new TablaDatos();
        $cabecera = array('#','NOMBRE','ESTADO', '<center>EDITAR</center>', '<center>ACT. / NO ACT.</center>');
        $TABLA->setCabeceraTabla($cabecera);
        $TABLA->setDataArray($data);
        $TABLA->crearTabla();             
    }
}

